<layout name='Layout/layout_main' />
<script type="text/javascript" src="__PUBLIC__/editor/kindeditor.js"></script>
<script type="text/javascript" src="__PUBLIC__/editor/kindeditor.setting.js"></script>
<script type="text/javascript">
	// 加载编辑器
	var top_menu;
	function popup_contact(){
		winopen("{:U('popup/contact')}",730,574);
	}
	
	function send(flag) {
		$("#to").val("");
		$("#recever .address_list span").each(function() {
			$("#to").val($("#to").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
		})
		$("#cc").val("");
		$("#carbon_copy .address_list span").each(function() {
			$("#cc").val($("#cc").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
		})

		$("#bcc").val("");
		$("#blind_carbon_copy .address_list span").each(function() {
			$("#cc").val($("#cc").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
		})
		if ($("#to").val().indexOf("@") < 1) {
			alert("请选择收件人");
			$("#recever letter").focus();
			return
		}
		if ($("#mail_title").val().length < 2) {
			alert('请输入标题');
			return
		}
		editor.sync();
		if(check_form("form_send")){
			if (flag) {
				sendForm("form_send", "{:U('send')}");
			} else {
				sendForm("form_send", "{:U('set_darft')}");
			}
		}
	}


	$(document).ready(function() {
		editor_init();
		

		$("td.recent li").click(function() {
			var html = '<span title="' + $(this).children("span").attr("title") + '"  onmousedown="return false">' + $(this).text() + ';</span>';
			$("#recever div.address_list").append(html);
		})
	})
	function switch_bcc() {
		if ($("#bcc").attr("class") == "") {
			$("#bcc").attr("class", "dis");
			$("#switch_bcc").text("\u25BC");
		} else {
			$("#bcc").attr("class", "");
			$("#switch_bcc").text("\u25B2");
		}
	}

	function switch_recent(obj) {
		if ($(obj).children("input").attr("class") == "nextfd") {
			$("td.recent").show();
			$("th.recent").show();
			$(obj).children("input").attr("class", "prefd");
		} else {
			$("td.recent").hide();
			$("th.recent").hide();
			$(obj).children("input").attr("class", "nextfd");
		}
	}
</script>
	<div class="title panel panel-default"><div class="panel-body"><h3 class="col-md-12">写邮件({$prefix})</h3></div>
	</div>
	<div class="operate panel panel-default">	<div class="panel-body">
		<div class="left">
			<a class="btn btn-default" onclick="send(true);">发送</a>
			<a class="btn btn-default" onclick="send(false);" >临时保管</a>
			<a class="btn btn-default" onclick="send(false);" >取消</a>
		</div>
	</div></div>
	<form method='post' id="form_send" name="form_send" enctype="multipart/form-data">
		<input type="hidden" id="ajax" name="ajax" value="0">
		<input type="hidden" id="add_file" name="add_file">
		<input type="hidden" id="to" name="to"/>
		<input type="hidden" id="cc" name="cc"/>
		<div class="">
			<div class="row form-horizontal">
				<div class="form-group col-md-12">
					<a class="col-md-2 control-label" for="name" onclick="popup_contact()">收件人*：</a>
					<div class="col-md-10">
						<div id="recever" class="inputbox">
							<div class="wrap" >
								<span class="address_list">
									<eq name="type" value="reply">{$vo.from|show_contact="edit"}</eq>
									<eq name="type" value="all">{$vo.from|show_contact="edit"}</eq>
								</span>
								<span class="text" >
									<input class="letter" type="text"  ></span>
							</div>
							<div class="search dropdown ">
								<ul class="dropdown-menu"></ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row form-horizontal">
				<div class="form-group col-md-12">
					<label class="col-md-2 control-label" for="name">
						抄送：
						<a onclick="switch_bcc();" id="switch_bcc" >&#9660;</a>
					</label>
					<div class="col-md-10">
						<div id="carbon_copy" class="inputbox">
							<div class="wrap" >
								<span class="address_list">
									<eq name="type" value="all">{$vo.cc|show_contact}</eq>
									&nbsp;
								</span>
								<span class="text" >
									<input class="letter" type="text"  ></span>
							</div>
							<div class="search dropdown ">
								<ul class="dropdown-menu"></ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row form-horizontal">
				<div class="form-group col-md-12">
					<label class="col-md-2 control-label" for="name">密送：</label>
					<div class="col-md-10">
						<div id="carbon_copy" class="inputbox">
							<div class="wrap" >
								<span class="address_list"></span>
								<span class="text" >
									<input class="letter" type="text"  ></span>
							</div>
							<div class="search dropdown ">
								<ul class="dropdown-menu"></ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row form-horizontal">
				<div class="form-group col-md-12">
					<label class="col-md-2 control-label" for="name">主题*：</label>
					<div class="col-md-10">
						<input type="text" id="name" name="name" id="mail_title" class="col-md-12"  check="require" msg="请输入主题"></div>
				</div>
			</div>
			<div class="row form-horizontal hidden-phone">
				<div class="form-group col-md-12">
					<label class="col-md-2 control-label" for="name">附件：</label>
					<div class="col-md-10">
						<include file="Layout:uploader" />
				</div>
			</div>
			<div class="row form-horizontal">
				<div class="form-group col-md-12">
					<textarea id="content" name="content" class="col-md-12">
						</br></br></br></br>
						<hr>
						<div style="background-color: #b6e3fc;">
							<p style="line-height:18px;padding-top:3px;">
								<b>&nbsp;发件人：</b>{$vo.from|show_contact}
							</p>
							<p style="line-height:18px;">
								<b>&nbsp;日期：</b>{$vo.create_time|toDate='Y年m月d日 H:i'}
							</p>
							<p style="line-height:18px;">
								<b>&nbsp;收件人：</b>{$vo.to|show_contact}
							</p>
							<gt name="vo.cc|strlen" value="2">
								<p style="line-height:18px;">
									<b>&nbsp;抄送：</b>{$vo.cc|show_contact}
								</p>
							</gt>
							<p style="line-height:18px;padding-bottom:3px;">
								<b>&nbsp;主题：</b>{$vo.name}
							</p>
						</div>
					{$vo.content}
					</textarea>
				</div>
			</div>
		</div>
	</form>
</div>